package com.jiatuxueyuan.sentinel.demo;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/sentinel")
public class DemoController {


    @GetMapping("/hello")
    @SentinelResource(value = "HelloWorld", fallback = "helloError")
    public String helloworld() {
        System.out.println("hello world");
        return "hello, world";
    }

    public String helloError() {
        System.out.println("hello error");
        return "hello error";
    }
}
